﻿Imports AFS.Aspnet.Collaboration.Site.ArbAuf
Imports AFS.Aspnet.Collaboration.Site.MandateAufstellung
Imports System.ServiceModel

' HINWEIS: Mit dem Befehl "Umbenennen" im Kontextmenü können Sie den Klassennamen "AFSForMetroService" sowohl im Code als auch in der SVC-Datei und der Konfigurationsdatei ändern.
' HINWEIS: Wählen Sie zum Starten des WCF-Testclients zum Testen dieses Diensts AFSForMetroService.svc oder AFSForMetroService.svc.vb im Projektmappen-Explorer aus, und starten Sie das Debuggen.

'Version: 	rel v1.0.0.2
'<ServiceModel.ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
Public Class AFSForMetroService
    Implements IAFSForMetroService

    Public NoMandateDB As Boolean = False
    Public NoDB As Boolean = False

    Private ReadOnly Property Context As ICallbackInterface
        Get
            Return OperationContext.Current.GetCallbackChannel(Of ICallbackInterface)()
        End Get
    End Property

    Sub New()
        If listofmandate.Count = 0 Then
            ' RefreshList()
            AutomaticUploadToBackYardServer.InitTimer()
        End If

        Dim initPathDB = DbPath()
        Dim InitPathMandate = MandateDBPath()


        If initPathDB <> "" Then
            Dim ff As New SQLite.SQLiteConnectionStringBuilder
            ff.ConnectionString = "DbLinqProvider=Sqlite ; data source=" & DbPath()

            Dim con As New SQLite.SQLiteConnection(ff.ToString)
            db = New AFS.Aspnet.Collaboration.Site.ArbAuf.Main(con)
        Else
            My.Computer.FileSystem.WriteAllText(files, "Init ArbeitsaufzeichnungenDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            NoDB = True
        End If

        If InitPathMandate <> "" Then
            Dim mand As New SQLite.SQLiteConnectionStringBuilder
            mand.ConnectionString = "DbLinqProvider=Sqlite ; data source=" & MandateDBPath()

            Dim mandcon As New SQLite.SQLiteConnection(mand.ToString)
            mandateDb = New MandateAufstellung.Main(mandcon)
        Else
            My.Computer.FileSystem.WriteAllText(files, "Init MandateDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            NoMandateDB = True
        End If

    End Sub

#Region "Mandate"

    Public Sub RetrieveAllSaveMandate() Implements IAFSForMetroService.RetrieveAllSaveMandate
        If NoMandateDB = False Then
            Dim a = (From b In mandateDb.MandateAnzahlen
                    Select b).ToList

            listofmandate = a

            Context.RetrievedMandate(listofmandate)
        Else
            My.Computer.FileSystem.WriteAllText(files, "Init MandateDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            Context.RetrievedMandate(Nothing)
        End If
    End Sub

    Public Sub AddNewMandate(a As List(Of MandateAnzahlen)) Implements IAFSForMetroService.AddNewMandate
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init MandateDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init MandateDB failed" & Date.Now.ToString)
            Context.AddOperationSucceed(rettype)
            Exit Sub
        End If

        Try
            mandateDb.MandateAnzahlen.InsertAllOnSubmit(a)
            mandateDb.SubmitChanges()
            rettype.OpSucceeded = True
            rettype.ErrorType = Nothing
            rettype.ReturnValue = a.ToList
        Catch ex As Exception
            rettype.ErrorType = ex
            rettype.OpSucceeded = False
        End Try
        Context.AddOperationSucceed(rettype)
    End Sub

    Public Sub EditMandat(Mandat As MandateAnzahlen) Implements IAFSForMetroService.EditMandat
        Dim rettype As New SuccessReturnType

        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init MandateDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init MandateDB failed" & Date.Now.ToString)
            Context.AddOperationSucceed(rettype)
            Exit Sub
        End If

        Try

            Dim a = From b In mandateDb.MandateAnzahlen
                    Where b.ID = Mandat.ID
                    Select b


            mandateDb.MandateAnzahlen.DeleteAllOnSubmit(a)
            'mandateDb.SubmitChanges()
            mandateDb.MandateAnzahlen.InsertOnSubmit(Mandat)
            mandateDb.SubmitChanges()
            rettype.OpSucceeded = True
            rettype.ErrorType = Nothing
            rettype.ReturnValue = Mandat
        Catch ex As Exception
            rettype.ErrorType = ex
            rettype.OpSucceeded = False
        End Try
        Context.EditOperationSucceed(rettype)
    End Sub

    Public Sub SearchForMandate(datum As String, rayon As String, type As String) Implements IAFSForMetroService.SearchForMandate
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init MandateDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init MandateDB failed" & Date.Now.ToString)
            Context.AddOperationSucceed(rettype)
            Exit Sub
        End If
        Dim ss
        Try
            ss = search(datum, rayon, type)
            Context.SearchMandate(ss)
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
            Context.SearchMandateOpSuccess(rettype)
        End Try
    End Sub

    Public Sub DeleteMandat(ByVal id As String) Implements IAFSForMetroService.DeleteMandat
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init MandateDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init MandateDB failed" & Date.Now.ToString)
            Context.AddOperationSucceed(rettype)
            Exit Sub
        End If

        Try
            Dim a = From b In mandateDb.MandateAnzahlen
                    Where b.ID = id
                    Select b

            mandateDb.MandateAnzahlen.DeleteAllOnSubmit(a)
            mandateDb.SubmitChanges()

            If CheckDeletionById(id) Then
                rettype.OpSucceeded = True
                rettype.ReturnValue = a.ToList
            Else
                rettype.OpSucceeded = False
                rettype.ErrorType = New Exception("deletion failed ")
            End If
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
        End Try
        Context.DeleteOperationSucceed(rettype)
    End Sub

    Private Function CheckDeletionById(ByVal id As String) As Boolean
        Dim a = From b In mandateDb.MandateAnzahlen
                Where b.ID = id
                Select b

        If a.Count = 0 Then
            Return True
        Else
            Return False
        End If
    End Function

    Public Sub DeleteMandateByDates(dates As String) Implements IAFSForMetroService.DeleteMandateByDates
        Dim rettype As New SuccessReturnType

        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init MandateDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init MandateDB failed" & Date.Now.ToString)
            Context.AddOperationSucceed(rettype)
            Exit Sub
        End If

        Try
            Dim a = From b In mandateDb.MandateAnzahlen
                    Where b.Datum = dates
                    Select b

            mandateDb.MandateAnzahlen.DeleteAllOnSubmit(a)
            mandateDb.SubmitChanges()

            rettype.OpSucceeded = True
            rettype.ErrorType = Nothing
            rettype.ReturnValue = a.ToList
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
        End Try
        Context.DeleteOperationSucceed(rettype)
    End Sub

    Public Sub AddNewMandat(aa As MandateAnzahlen) Implements IAFSForMetroService.AddNewMandat
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init MandateDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init MandateDB failed" & Date.Now.ToString)
            Context.AddOperationSucceed(rettype)
            Exit Sub
        End If

        Try
            If aa.ID Is Nothing Or aa.ID = "" Then
                aa.ID = System.Guid.NewGuid.ToString
                mandateDb.MandateAnzahlen.InsertOnSubmit(aa)
                mandateDb.SubmitChanges()
            Else
                Dim ff = From a In mandateDb.MandateAnzahlen
                         Where a.ID = aa.ID
                         Select a

                If ff.Count = 0 Then
                    mandateDb.MandateAnzahlen.InsertOnSubmit(aa)
                    mandateDb.SubmitChanges()
                Else
                    EditMandat(aa)
                End If
            End If
            rettype.OpSucceeded = True
            rettype.ReturnValue = aa
            rettype.ErrorType = Nothing
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
        End Try
        Context.AddOperationSucceed(rettype)
    End Sub

    Public Sub ClearMandateTable() Implements IAFSForMetroService.CleareMandateTable
        Dim rettype As New SuccessReturnType
        Try
            Dim ff = (From b In mandateDb.MandateAnzahlen).ToList
            My.Computer.FileSystem.WriteAllText(files, "clear MandateDB: " & ff.Count & ";" & vbCrLf, True)
            For Each a In ff

                mandateDb.MandateAnzahlen.DeleteOnSubmit(a)
            Next
            If CheckClearancy() Then
                rettype.OpSucceeded = True
                rettype.ErrorType = Nothing
            End If
        Catch ex As Exception
            My.Computer.FileSystem.WriteAllText(files, "clear MandateDB failed" & Date.Now.ToString & vbCrLf & ex.Message.ToString & vbCrLf & ex.Source.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
        End Try
        Context.ClearOperationSucceed(rettype)
    End Sub


    Private Function CheckClearancy()
        If mandateDb.MandateAnzahlen.Count = 0 Then
            Return True
        Else
            Return False
        End If
    End Function
#End Region

#Region "WorkdayAddance"

    Public Sub AddNewWorkDay(workday As ArbAuf.Arbeitsaufzeichnung) Implements IAFSForMetroService.AddNewWorkDay
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init ArbAufDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init ArbAufDB failed" & Date.Now.ToString)
            Context.AddWDOperationSucceed(rettype)
            Exit Sub
        End If



        Try
            db.Arbeitsaufzeichnung.InsertOnSubmit(workday)
            db.SubmitChanges()
            rettype.OpSucceeded = True
            rettype.ErrorType = Nothing
            rettype.ReturnValue = workday
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
        End Try
        Context.AddWDOperationSucceed(rettype)
    End Sub

    Public Sub DeleteWorkDay(id As String) Implements IAFSForMetroService.DeleteWorkDay
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init ArbAufDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init ArbAufDB failed" & Date.Now.ToString)
            Context.DeleteWDOperationSucceed(rettype)
            Exit Sub
        End If

        Dim a = From b In db.Arbeitsaufzeichnung
                Where b.ID = id
                Select b

        If a IsNot Nothing Then
            Try
                db.Arbeitsaufzeichnung.DeleteAllOnSubmit(a)
                db.SubmitChanges()
                rettype.OpSucceeded = True
                rettype.ErrorType = Nothing
                rettype.ReturnValue = a.ToList
            Catch ex As Exception
                rettype.OpSucceeded = False
                rettype.ErrorType = ex
            End Try

        Else
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("ID not found in db...")
        End If
        Context.DeleteWDOperationSucceed(rettype)
    End Sub

    Public Sub EditWorkDay(eWorkday As ArbAuf.Arbeitsaufzeichnung) Implements IAFSForMetroService.EditWorkDay
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init ArbAufDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init ArbAufDB failed" & Date.Now.ToString)
            Context.EditWDOperationSucceed(rettype)
            Exit Sub
        End If

        Dim a = From b In db.Arbeitsaufzeichnung
                Where b.ID = eWorkday.ID
                Select b
        Try

            For Each b In a
                Me.DeleteWorkDay(b.ID)
            Next


            Me.AddNewWorkDay(eWorkday)


            rettype.OpSucceeded = True
            rettype.ErrorType = Nothing
            rettype.ReturnValue = eWorkday
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
        End Try
        Context.EditWDOperationSucceed(rettype)
    End Sub

    Public Sub EnumerateAllWorkdays() Implements IAFSForMetroService.EnumerateAllWorkdays
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init ArbAufDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init ArbAufDB failed" & Date.Now.ToString)
            Context.EnumeratedWorkdaysSucceed(rettype)
            Exit Sub
        End If

        Dim a = (From b In db.Arbeitsaufzeichnung
        Select b).ToList

        Context.EnumeratedWorkdays(a)
    End Sub

    Public Sub EnumerateWorkdayForMonth(MonthNumber As String) Implements IAFSForMetroService.EnumerateWorkdayForMonth
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init ArbAufDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init ArbAufDB failed" & Date.Now.ToString)
            Context.EnumeratedWorkdaysSucceed(rettype)
            Exit Sub
        End If
        Dim a = (From b In db.Arbeitsaufzeichnung
                Where b.Monat = MonthNumber
                Select b).ToList

        Context.EnumeratedWorkdays(a)
    End Sub

    Public Sub ClearWorkdayTable() Implements IAFSForMetroService.ClearWorkDayTable
        Dim rettype As New SuccessReturnType
        Try
            Dim ff = (From a In db.Arbeitsaufzeichnung).ToList

            db.Arbeitsaufzeichnung.DeleteAllOnSubmit(ff)
            rettype.OpSucceeded = CheckClearancyWorkday()
            rettype.ErrorType = Nothing
        Catch ex As Exception
            My.Computer.FileSystem.WriteAllText(files, "clear MandateDB failed" & Date.Now.ToString & vbCrLf & ex.Message.ToString & vbCrLf & ex.Source.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
        End Try

        Context.ClearOperationSucceed(rettype)
    End Sub

    Private Function CheckClearancyWorkday()
        If db.Arbeitsaufzeichnung.Count = 0 Then
            Return True
        Else
            Return False
        End If
    End Function

#End Region


#Region "ArbeitsTypen"
    Public Sub AddArbeitsType(typ As Typen) Implements IAFSForMetroService.AddArbeitsType
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init ArbAufDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init ArbAufDB failed" & Date.Now.ToString)
            Context.AddATypenOperationSucceed(rettype)
            Exit Sub
        End If

        Try
            db.Typen.InsertOnSubmit(typ)
            db.SubmitChanges()
            rettype.OpSucceeded = True
            rettype.ErrorType = Nothing
            rettype.ReturnValue = typ
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
        End Try
        Context.AddATypenOperationSucceed(rettype)
    End Sub

    Public Sub DeleteArbeitsType(type As Typen) Implements IAFSForMetroService.DeleteArbeitsType
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init ArbAufDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init ArbAufDB failed" & Date.Now.ToString)
            Context.DeleteATypenOperationSucceed(rettype)
            Exit Sub
        End If

        Dim a = From b In db.Typen
                Where b.ID
                Select b
        Try
            If a IsNot Nothing Then
                db.Typen.DeleteAllOnSubmit(a)
                db.SubmitChanges()
                rettype.OpSucceeded = True
                rettype.ErrorType = Nothing
                rettype.ReturnValue = a.ToList
            Else
                rettype.OpSucceeded = False
                rettype.ErrorType = New Exception("id not found")
            End If
        Catch ex As Exception
            rettype.ErrorType = ex
            rettype.OpSucceeded = False
        End Try
        Context.DeleteATypenOperationSucceed(rettype)
    End Sub

    Public Sub EditArbeitType(type As Typen) Implements IAFSForMetroService.EditArbeitType
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init ArbAufDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init ArbAufDB failed" & Date.Now.ToString)
            Context.EditATypenOperationSucceed(rettype)
            Exit Sub
        End If

        Dim a = From b In db.Typen
                Where b.ID = type.ID
                Select b

        Try
            If a IsNot Nothing Then
                db.Typen.DeleteAllOnSubmit(a)
            End If

            db.Typen.InsertOnSubmit(type)
            rettype.OpSucceeded = True
            rettype.ErrorType = Nothing
            rettype.ReturnValue = type
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
        End Try
        Context.EditATypenOperationSucceed(rettype)
    End Sub

    Public Sub EnumerateArbeitsTypen() Implements IAFSForMetroService.EnumerateArbeitsTypen
        Dim rettype As New SuccessReturnType
        If NoMandateDB Then
            My.Computer.FileSystem.WriteAllText(files, "Init ArbAufDB failed" & Date.Now.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = New Exception("Init ArbAufDB failed" & Date.Now.ToString)
            Context.EnumeratedATypenSucceed(rettype)
            Exit Sub
        End If
        Try
            Dim a = (From b In db.Typen
                    Select b).ToList

            Context.EnumeratedATypen(a)
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
            Context.EnumeratedATypenSucceed(rettype)
        End Try

    End Sub

    Public Sub ClearTypenTable() Implements IAFSForMetroService.ClearTypenTable
        Dim rettype As New SuccessReturnType
        Try
            Dim ff = (From a In db.Typen).ToList

            db.Typen.DeleteAllOnSubmit(ff)
            If CheckClearancyTypen() Then
                rettype.OpSucceeded = True
                rettype.ReturnValue = Nothing
                rettype.ErrorType = Nothing
            End If
        Catch ex As Exception
            My.Computer.FileSystem.WriteAllText(files, "clear MandateDB failed" & Date.Now.ToString & vbCrLf & ex.Message.ToString & vbCrLf & ex.Source.ToString & ";" & vbCrLf, True)
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
            rettype.ReturnValue = Nothing
        End Try
        Context.ClearATypenOperationSucceed(rettype)
    End Sub

    Private Function CheckClearancyTypen() As Boolean
        If db.Typen.Count = 0 Then
            Return True
        Else
            Return False
        End If
    End Function

#End Region

#Region "db tasks"

    Public Sub DownloadDbFromBackServerManual() Implements IAFSForMetroService.DownloadDbFromBackServerManual
        Dim rettype As New SuccessReturnType
        Try
            Dim retval = DownloadDatabaseFileFromBackFallServer()
            If retval Then
                InitArbeitsaufzeichnungenDBFile()
                rettype.OpSucceeded = True
            Else
                rettype.OpSucceeded = False
            End If
            rettype.ErrorType = Nothing
            rettype.ReturnValue = "ArbeitsaufzeichnungenDB"
            rettype.OpSucceeded = True
        Catch ex As Exception
            rettype.ErrorType = ex
            rettype.ReturnValue = "ArbeitsaufzeichnungenDB"
            rettype.OpSucceeded = False
        End Try

        Context.DbDownloadSucceeded(rettype)
    End Sub

    Public Sub DownloadMandateDbFromBackServerManual() Implements IAFSForMetroService.DownloadMandateDbFromBackServerManual
        Dim rettype As New SuccessReturnType
        Try
            Dim retval = DownloadMandateFileFromBackFallServer()
            If retval Then
                InitMandateDBFile()
                rettype.OpSucceeded = True
            Else
                rettype.OpSucceeded = False
            End If
            rettype.ErrorType = Nothing
            rettype.ReturnValue = "MandateDB"

        Catch ex As Exception
            rettype.ErrorType = ex
            rettype.ReturnValue = "MandateDB"
            rettype.OpSucceeded = False
        End Try
        Context.DbDownloadSucceeded(rettype)
    End Sub

    Public Sub UploadDBToBackServerManual() Implements IAFSForMetroService.UploadDBToBackServerManual
        Dim rettype As New SuccessReturnType
        Try
            Dim retval = UploadDatabaseFileToBackFallServer()
            If retval Then
                rettype.OpSucceeded = True
            Else
                rettype.OpSucceeded = False
            End If
            rettype.ErrorType = Nothing
            rettype.ReturnValue = Nothing
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
            rettype.ReturnValue = "ArbZeitDB upload failed..."
        End Try
        Context.DbUploadSucceeded(rettype)
    End Sub

    Public Sub UploadMandateDbToBackServerManual() Implements IAFSForMetroService.UploadMandateDbToBackServerManual
        Dim rettype As New SuccessReturnType
        Try
            Dim retval = UploadMandateFileToBackFallServer()
            If retval Then
                rettype.OpSucceeded = True
            Else
                rettype.OpSucceeded = False
            End If
            rettype.ErrorType = Nothing
            rettype.ReturnValue = "Mandate Db upload succeed..."
        Catch ex As Exception
            rettype.OpSucceeded = False
            rettype.ErrorType = ex
            rettype.ReturnValue = "Upload MandateDb Failed"
        End Try

    End Sub
#End Region


#Region "back service"
    Public Sub ReadStatusFile() Implements IAFSForMetroService.ReadStatusFile
        Context.StatusFileRead(AutomaticUploadToBackYardServer.ReadStatusFile)
    End Sub
#End Region

End Class
